package com.ycfmedical.bed.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ycfmedical.bed.R;
import com.ycfmedical.bed.adapter.HisMedicineCheckAdapter;
import com.ycfmedical.bed.local.entity.BillRecords;
import com.ycfmedical.bed.present.HisCheckMedicinePrensenter;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import cn.droidlover.xdroidmvp.mvp.XFragment;
import cn.droidlover.xrecyclerview.XRecyclerContentLayout;

/**
 * Created by yf on 2017-04-30.
 */

public class CheckMedicineFragement extends XFragment<HisCheckMedicinePrensenter> {
    @BindView(R.id.billRecords)
    XRecyclerContentLayout billRecords;
    HisMedicineCheckAdapter adapter;
    @BindView(R.id.billResult)
    XRecyclerContentLayout billResult;
    Unbinder unbinder;

    @Override
    public void initData(Bundle savedInstanceState) {
        adapter = new HisMedicineCheckAdapter(getContext());
        billRecords.getRecyclerView().verticalLayoutManager(getContext());
        billRecords.getRecyclerView().setAdapter(adapter);
        billRecords.getRecyclerView().setRefreshEnabled(false);

        billResult.setVisibility(View.GONE);
        getP().loadData();

    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_his_billcheck;
    }

    @Override
    public HisCheckMedicinePrensenter newP() {
        return new HisCheckMedicinePrensenter();
    }


    public void showData(List<BillRecords> billList) {
        adapter.addData(billList);
        adapter.notifyDataSetChanged();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
